<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Category extends CI_Controller{
  public function loadModel(){
    $this->load->model('category_model','category',TRUE);
  }
  public function index(){
    
  }
  public function create(){
    $this->loadModel();
    $param = $_POST;    
    $this->category->create($param);
  }
  public function update(){
    $this->loadModel();
    $param = $_POST;
    $this->category->update($param);
  }
  public function delete(){
    $this->loadModel();
    $param = $_POST;
    $this->category->delete($param);
  }
  public function read(){
    $this->loadModel();
    echo $this->category->readAll();
  }
  public function createCategory(){
    $this->loadModel();
    $data['allCategory'] = json_decode($this->category->readAll());
    $this->load->view('header');
    $this->load->view('create_category',$data);
    $this->load->view('footer');
  }
}